#include <iostream>
#include <vector>
#include <list>
#include <queue>
#include <string>
#include <time.h>
#include <chrono>
#include <random>
#include <math.h>
#include <memory>
#include <stdexcept>
#include "SDL.h"
#include "SDL_image.h"
#include "SDL_ttf-2.0.11\include\SDL_ttf.h"

using namespace std;

//SDL constants
const int SCREEN_WIDTH = 920;
const int SCREEN_HEIGHT = 720;
const SDL_Color DEFAULT_SDL_BACKGROUND_COLOR = {255,255,255,0};
const SDL_Color DEFAULT_SDL_TEXT_COLOR = {255,255,255,0};
const int DEFAULT_GRID_SIZE[2] = {14,20}; //{width,height}
const double drawZone = 0.8;

#ifndef WINDOW_H
#define WINDOW_H

#define SDL_Black Window::SDL_GetColor(0, 0, 0, 255)
#define SDL_White Window::SDL_GetColor(255, 255, 255, 255)
 
//What we think our window class should look like
class Window {
public:
    //Start SDL and TTF, create the window and renderer
	static void Init(std::string title = "SDL");
    static void Init(int windowwidth, int windowheight,std::string title = "SDL");
    //Quit SDL and TTF
    static void Quit();
	//Draw a SDL_Texture to the screen at dstRect with various other options
	static void Draw(SDL_Texture *tex, SDL_Rect &dstRect, SDL_Rect *clip = NULL, float angle = 0.0, int xPivot = 0, int yPivot = 0, SDL_RendererFlip flip = SDL_FLIP_NONE);
	static void DrawTiles(vector<string> image);
	void DrawTiles(vector<string> image, const std::string& fontFile, SDL_Color textColor, int fontSize); //With more options
    //Load an image directly to texture using SDL_image's built in function IMG_LoadTexture
    static SDL_Texture* LoadImage(const std::string &file);
    //Render some text
    static SDL_Texture* RenderText(const std::string &message, const std::string &fontFile, SDL_Color color, int fontSize);
    //Clear window
    static void Clear(SDL_Color color = SDL_Black);
    //Present renderer
    static void Present();
    //Get the window's box
    static SDL_Rect Box();
	//Set the box to a specific location 
	static SDL_Rect SetBox(int x, int y); //with the default grid size
	static SDL_Rect SetBox(int x, int y, int w, int h); //with a chosen grid size
	static SDL_Rect GridBox(int x, int y); //with default grid size, but x and y refer to grid placement, not absolute x and y
	static SDL_Rect GridLine(int y); //With default grid height, but y refers to the line chosen

	static void DrawDot(int x, int y, int radius=5, SDL_Color=SDL_Black);
	static void DrawLine(int x1,int y1, int x2, int y2, SDL_Color color=SDL_Black);
	static void DrawRegularPolygon(unsigned int sides, SDL_Color color= SDL_Black);
	
	static SDL_Color SDL_GetColor(int r, int g, int b, int a);
 
private:
    static std::unique_ptr<SDL_Window, void (*)(SDL_Window*)> mWindow;
    static std::unique_ptr<SDL_Renderer, void (*)(SDL_Renderer*)> mRenderer;
    static SDL_Rect mBox;
};
 
#endif